#ifndef __IMAGE_H_LULY_
#define __IMAGE_H_LULY_
#include "PLATFORM.h"
#ifdef _ANDROID_PLATFORM__
#include "SDL_image.h"
#else
#include <SDL2/SDL_image.h>
#endif

#include <string>
#include <unordered_map>
class _Image {
 private:
  _Image() {}
  std::unordered_map<std::string, SDL_Surface*> image_surface_list;

 public:
  static _Image& getInstance() {
    static _Image instance;
    return instance;
  }
  void loadImage(std::string fileName, std::string imageId);
  bool hasImage(std::string imageId);
  void destroyImageSurface(std::string imageId);

  //绘制imageId对应的图片，只绘制一帧
  void draw(std::string imageId, int x, int y);  //不旋转，不缩放
  void draw(std::string imageId, int x, int y, double scale,
            double angle);  //旋转或缩放
  //绘制某一部分
  void draw(std::string imageId, SDL_Rect cut, int x, int y, double destWidth,
            double destHeight, double angle = 0);

  SDL_Surface* getImageSurface(std::string imageId);

  ~_Image();
};

#endif